// css转换 backgroundColor->background-color
export const getKebabCase = (str: string) => {
  let temp = str.replace(/[A-Z]/g, function (i) {
    return "-" + i.toLowerCase()
  })
  if (temp.slice(0, 1) === "-") {
    temp = temp.slice(1) //如果首字母是大写，执行replace时会多一个_，需要去掉
  }
  return temp
}

// background-color->backgroundColor
export const getCamelCase = (str: string) => {
  return str.replace(/-([a-z])/g, function (_, i) {
    return i.toLowerCase()
  })
}

// background-color->backgroundColor
export const getCamelCase2 = (str: string) => {
  const arr: Array<string> = str.split("-")
  return arr
    .map((item, index) => {
      if (index === 0) {
        return item
      } else {
        return item.charAt(0).toUpperCase() + item.slice(1)
      }
    })
    .join("")
}
